package com.ty.spring.listener;

import com.ty.spring.config.properties.TyProperties;
import com.ty.utils.ip.IPSeeker;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * SpringBoot应用启动的监听器
 *
 * @Author Tommy
 * @Date 2024/4/16
 */
@Component
@Slf4j
public class ApplicationListener implements ApplicationRunner {

    @Autowired
    private TyProperties tyProperties;

    /**
     * 项目启动完毕后，执行此方法
     */
    @Override
    public void run(ApplicationArguments args) throws Exception {
        IPSeeker.setDB(tyProperties.getIpDbPath());
        log.info("项目启动完成，可以访问了！IP_DB_Path: {}", IPSeeker.getDB());
    }
}
